package com.CST.controller.zx;

import com.CST.dto.zx.ZxUserProjectRelationDTO;
import com.CST.dto.zx.ZxUserProjectRelationPageDTO;
import com.CST.dto.zx.addUserDTO;
import com.CST.service.zx.ZxUserProjectRelationService;
import com.CST.util.Result;
import com.CST.vo.zx.ZxProjectTypeList;
import com.CST.vo.zx.ZxUserListVO;
import com.CST.vo.zx.ZxUserProjectRelationVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qtx
 * @since 2023-06-07
 */
@Api(tags = {"专项经费-项目档案-用户与项目关系关联"})
@RestController
@RequestMapping("/zxUserProjectRelation")
public class ZxUserProjectRelationController {
    @Autowired
    private ZxUserProjectRelationService service;

    @ApiOperation("主数据新增")
    @PostMapping("/save")
    public Result<Boolean> save(@RequestBody ZxUserProjectRelationDTO dto) {
        return Result.success(service.save(dto));
    }


    @ApiOperation("主页查询")
    @PostMapping("/mainPage")
    public Result<IPage<ZxUserProjectRelationVO>> mainPage(@RequestBody ZxUserProjectRelationPageDTO dto) {
        return Result.success(service.mainPage(dto));
    }

    @ApiOperation("主数据删除")
    @DeleteMapping("/removeById")
    public Result<Boolean> removeById(@RequestParam Long id) {
        return Result.success(service.removeByIdNew(id));
    }


    @ApiOperation("添加人员")
    @PostMapping("/userList")
    public Result<List<ZxUserListVO>> userList(@RequestBody addUserDTO dto){
        return Result.success(service.userList(dto));
    }

    @ApiOperation("项目类别下拉列表")
    @GetMapping("/projectList")
    public Result<List<ZxProjectTypeList>> projectList(String entryCode){
        return Result.success(service.projectList(entryCode));
    }
}
